
package za.ac.cput.peterjohn.DesignPatternPrincipals.Behavioral.Memento.Model;


public class DietInfo 
{
    String personName;
    int dayNumber;
    int weight;

    public DietInfo(String personName, int dayNumber, int weight) 
    {
        this.personName = personName;
        this.dayNumber = dayNumber;
        this.weight = weight;
    }

    @Override
    public String toString() { return "DietInfo{" + "personName=" + personName + ", dayNumber=" + dayNumber + ", weight=" + weight + '}'; }

    public void setDayNumberAndWeight(int dayNumber , int weight)
    {
        this.weight = weight;
        this.dayNumber = dayNumber;
    }
    
    public Memento save(){ return new Memento(personName, dayNumber, weight); }
    
    public void restore(Object objMemento)
    {
        Memento memento = (Memento) objMemento;
        
        personName = memento.mementoPersonName;
        dayNumber = memento.mementoDayNumber;
        weight = memento.mementoweight;
    }
    
    
    private static class Memento 
    {
        String mementoPersonName;
        int mementoDayNumber;
        int mementoweight;

        public Memento(String mementoPersonName, int mementoDayNumber, int mementoweight) 
        {
            this.mementoPersonName = mementoPersonName;
            this.mementoDayNumber = mementoDayNumber;
            this.mementoweight = mementoweight;
        }
    }
}